﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Wise.Entities;

namespace NHI.Sync.Tools.Forms
{
    /// <summary>
    /// SaveConfig.xaml 的交互逻辑
    /// </summary>
    public partial class Form_Save : UserControl
    {
        public Form_Save()
        {
            InitializeComponent();
        }


        public void OnPrevious_Click(object o, EventArgs e)
        {
            MainWindow.Current.tab_2.IsEnabled = true;
            MainWindow.Current.tab_2.IsSelected = true;
        }

        public void OnNext_Click(object o, EventArgs e)
        {
            MainWindow.Current.tab_5.IsEnabled = true;
            MainWindow.Current.tab_5.IsSelected = true;
            MainWindow.Current.frame_5.LoadData();


        }



        protected void DoSaveConfig(Object o, EventArgs e)
        {
            Microsoft.Win32.SaveFileDialog ofd = new Microsoft.Win32.SaveFileDialog();
            ofd.DefaultExt = ".json";
            ofd.Filter = "数据迁移配置文件|*.json";
            ofd.Title = "打开配置文件";
            if (ofd.ShowDialog() == true)
            {
                try
                {
                    MyDbConfig.Current.Write(ofd.FileName);
                }
                catch (Exception exp)
                {
                    MyDbConfig.Current = new MyDbConfig();
                    MessageBox.Show(exp.Message);
                }
                MainWindow.Current.ShowSuccess($"已保存到{ofd.FileName}");
            }
        }

        protected void DoSaveMapping(Object o, EventArgs e)
        {
            //Microsoft.Win32.SaveFileDialog ofd = new Microsoft.Win32.SaveFileDialog();
            //ofd.DefaultExt = ".xlsx";
            //ofd.Filter = "数据映射文件|*.xlsx";
            //ofd.Title = "打开映射文件";
            //if (ofd.ShowDialog() == true)
            //{
            //    try
            //    {
            //        MyDbConfig.Current.Write(ofd.FileName);
            //    }
            //    catch (Exception exp)
            //    {
            //        MyDbConfig.Current = new MyDbConfig();
            //        MessageBox.Show(exp.Message);
            //    }
            //    MainWindow.Current.ShowSuccess($"已保存到{ofd.FileName}");
            //}
        }
    }
}
